<template>

  <view class="body" v-bind:style="{'padding-top': padtop + 'px'}">
    <view class="nav-bar" v-bind:style="{top: top + 'px'}">
      <view :class="{top:true  , 'box-shadow': shadow == 0 }">
        <view class="nav">
          <view :class="{select:true,cur:_num==1}" data-num="1" @click='onSwitch'>
            推荐
          </view>
          <view :class="{select:true,cur:_num==2}" data-num="2" @click='onSwitch'>
            最新
          </view>
          <view :class="{select:true,cur:_num==3}" data-num="3" @click='onSwitch'>
            关注
          </view>
        </view>
        <view :class="{showSearch:true,hide:land}" @click='goFenxiang'>
          <!-- <image src="{{userInfo.avatarUrl}}"></image> -->
        </view>
        <view :class="{showSearch:true,hide:land}" @click='goFenxiang'>
          <image src="/static/images/user.png"></image>
        </view>
        <view class='search-top' @click='showSearch'>
          <!-- <icon class='iconfont icon-sousuo'></icon> -->
          <uni-icons type="search"></uni-icons>
        </view>
      </view>
      <view :class="{'hot-select':true,'box-shadow': shadow == 1}" v-if="show">
        <text data-index='1' @click='onPress' :class="[index==1?'bgc':'']">路况</text>
        <text data-index='2' @click='onPress' :class="[index==2?'bgc':'']">风光</text>
        <text data-index='3' @click='onPress' :class="[index==3?'bgc':'']">互助</text>
        <text data-index='4' @click='onPress' :class="[index==4?'bgc':'']">曝光</text>
        <text data-index='5' @click='onPress' :class="[index==5?'bgc':'']">其他</text>
      </view>
    </view>

    <!-- 最热开始 -->
    <view :class="[_num==2||_num==3?'hide':'']">
      <!-- 路况 -->
      <view :class="{hide:true,show:selNum==1}">
        <view style="display: none;">
          <image v-for="(item,i) in lukuangimages" :key="i" :src="item.coverPath" @load="onLukuangLoad" :id="item.id">
          </image>
        </view>
        <view class="sel-bgc" v-bind:style="{'height':scrollH + 'px'}">
          <view class="margin_bottom" style="width:100%">
            <view class="img_item">
              <block v-for="(item,i) in lukuangcol1" :key="i">
                <view class="left-img" @click='goVideo'>
                  <!-- //width:100%; -->
                  <image class="image-width" :src="item.coverPath" v-bind:style="{height:item.height+ 'px'}"></image>
                  <text v-if="item.isShow">{{item.content}}</text>
                  <view class="hotNews-num">
                    <image src="/static/images/bofangliang.png"></image>
                    <text>{{item.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item.videoSeconds == 10 }">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>
            <view class="img_item1">
              <block v-for="(item2,i2) in lukuangcol2" :key="i2">
                <view class="right-img" @click='goVIdoe'>
                  <!-- //width:100%; -->
                  <image class="image-width" :src="item2.coverPath" v-bind:style="{height:item2.height+ 'px'}"></image>
                  <text v-if="item2.isShow">{{item2.content}}</text>
                  <view class="hotNews-num">
                    <image src='/static/images/bofangliang.png'></image>
                    <text>{{item2.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item2.videoSeconds == 10 }">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>
          </view>
        </view>
      </view>

      <!-- 风光 -->
      <view :class="{hide:true,show:selNum==2}">
        <view style="display:none">
          <image v-for="(item,i) in fengguangimages" :key="i" :id="item.id" :src="item.coverPath"
            @load="onFengguangLoad"></image>
        </view>
        <view v-bind:style="{height:scrollH + 'px'}">
          <view style="width:100%" class='margin_bottom'>
            <view class="img_item">
              <block v-for="(item,i) in fengguangcol1" :key="i">
                <view class="left-img" @click='goVideo' :data-id='item.id' :data-index="i">
                  <image class="image-width" :src="item.coverPath" v-bind:style="{height:item.height+ 'px'}"></image>
                  <text v-if="item.isShow">{{item.content}}</text>
                  <view class='hotNews-num'>
                    <image src="/static/images/bofangliang.png"></image>
                    <text>{{item.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item.videoSeconds == 10}">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>
            <view class="img_item1">
              <block v-for="(item2,i2) in fengguangcol2" :key="i2">
                <view class="right-img" @click='goVIdoe' :data-id='item2.id' :data-index="i2">
                  <image class="image-width" :src="item2.coverPath" v-bind:style="{height:item2.height+ 'px'}"></image>
                  <text v-if="item2.isShow">{{item2.content}}</text>
                  <view class='hotNews-num'>
                    <image src='/static/images/bofangliang.png'></image>
                    <text>{{item2.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item2.videoSeconds == 10 }">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>
          </view>
        </view>
      </view>


      <!-- 互助 -->
      <view :class="{hide:true,show:selNum==3}">
        <view style="display:none">
          <image v-for="(item,i) in huzhuimages" :key="i" :id="item.id" :src="item.coverPath" @load="onHuzhuLoad">
          </image>
        </view>
        <view v-bind:style="{height:scrollH + 'px'}">
          <view style="width:100%" class='margin_bottom'>
            <view class="img_item">
              <block v-for="(item,i) in huzhucol1" :key="i">
                <view class="left-img" @click='goVideo' :data-id='item.id' :data-index='i'>
                  <image class="image-width" :src="item.coverPath" v-bind:style="{height:item.height+ 'px'}"></image>
                  <text v-if="item.isShow">{{item.content}}</text>
                  <view class='hotNews-num'>
                    <image src='/static/images/bofangliang.png'></image>
                    <text>{{item.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item.videoSeconds == 10 }">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>

            <view class="img_item1">
              <block v-for="(item2,i2) in huzhucol2" :key="i2">
                <view class="right-img" @click='goVIdoe' :data-id='item2.id' :data-index='i2'>
                  <image class="image-width" :src="item2.coverPath" v-bind:style="{height:item2.height+ 'px'}"></image>
                  <text v-if="item2.isShow">{{item2.content}}</text>
                  <view class='hotNews-num'>
                    <image src='/static/images/bofangliang.png'></image>
                    <text>{{item2.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item2.videoSeconds == 10 }">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>
          </view>
        </view>
      </view>

      <!-- 曝光 -->
      <view :class="{hide:true,show:selNum==4}">
        <view style="display:none">
          <image v-for="(item,i) in baoguangimages" :key="i" :id="item.id" :src="item.coverPath" @load="onBaoguangLoad">
          </image>
        </view>
        <view v-bind:style="{'height':scrollH + 'px'}">
          <view style="width:100%" class='margin_bottom'>
            <view class="img_item">
              <block v-for="(item,i) in baoguangcol1" :key="i">
                <view class="left-img" @click='goVideo' :data-id='item.id' :data-index="i">
                  <image class="image-width" :src="item.coverPath" v-bind:style="{height:item.height+ 'px'}"></image>
                  <text v-if="item.isShow">{{item.content}}</text>
                  <view class='hotNews-num'>
                    <image src='/static/images/bofangliang.png'></image>
                    <text>{{item.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item.videoSeconds == 10 }">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>
            <view class="img_item1">
              <block v-for="(item2,i2) in baoguangcol2" :key="i2">
                <view class="right-img" @click='goVIdoe' :data-id='item2.id' :data-index="i2">
                  <image class="image-width" :src="item2.coverPath" v-bind:style="{height:item2.height+ 'px'}">
                  </image>
                  <text v-if="item2.isShow">{{item.content}}</text>
                  <view class='hotNews-num'>
                    <image src='/static/images/bofangliang.png'></image>
                    <text>{{item2.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item2.videoSeconds == 10 }">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>
          </view>
        </view>
      </view>

      <!-- 其他 -->
      <view :class="{hide:true,show:selNum==5}">
        <view style="display:none">
          <image v-for="(item,i) in qitaimages" :key="i" :id="item.id" :src="item.coverPath" @load="onQitaLoad"></image>
          </image>
        </view>
        <view v-bind:style="{height:scrollH + 'px'}">
          <view style="width:100%" class='margin_bottom'>
            <view class="img_item">
              <block v-for="(item,i) in qitacol1" :key="i">
                <!-- <view class='left-img' @click='goVideo' > -->
                <view class="left-img" @click='goVideo' :data-id='item.id' :data-index='i'>
                  <image class="image-width" :src="item.coverPath" v-bind:style="{height:item.height+ 'px'}"></image>
                  <text v-if="item.isShow">{{item.content}}</text>
                  <view class='hotNews-num'>
                    <image src='/static/images/bofangliang.png'></image>
                    <text>{{item.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item.videoSeconds == 10}">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>
            <view class="img_item1">
              <block v-for="(item2,i2) in qitacol2" :key="i2">
                <view class="right-img" @click='goVIdoe' :data-id='item2.id' :data-index='i2'>
                  <image class="image-width" :src="item2.coverPath" v-bind:style="{height:item2.height+ 'px'}">
                  </image>
                  <text v-if="item2.isShow">{{item2.content}}</text>
                  <view class='hotNews-num'>
                    <image src='/static/images/bofangliang.png'></image>
                    <text>{{item2.playedTime}}</text>
                  </view>
                  <view :class="{iconbofang:true, hide:ture,show:item2.videoSeconds == 10 }">
                    <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                  </view>
                </view>
              </block>
            </view>
          </view>
        </view>
      </view>
    </view>
    <!-- 最热结束 -->

    <!-- 最新开始 -->
    <view :class="{newest:true,hide:_num==1||_num==3}">
      <view>
        <view style="display:none">
          <image v-for="(item,i) in newrows" :key="i" :src="item.coverPath" :id="item.id" @load="onzuixin"></image>
        </view>
        <block v-for="(itemName,index) in rows" :key="index">
          <view class='personal'>
            <image class="personal-img" :src="itemName.faceImage" @click='goHomepage' :data-id="itemName.userid">
            </image>
            <view class='name' @click='goHomepage' :data-id='itemName.userid'>
              <text class='userName'>{{itemName.name}}</text>
              <view class='enti'>
                <view class='time'>
                  <image src='/static/images/time.png'></image>
                  <text>{{itemName.createTime}}</text>
                </view>
                <view class='address'>
                  <image src='/static/images/weizhi.png'></image>
                  <text>{{itemName.city}}</text>
                </view>
              </view>
            </view>
            <view class='video' @click='goVideo' :data-id='itemName.id' :data-index='index'>
              <view :class="{myVideo:true,hide:itemName.videoSeconds==0}">
                <view class='coverVideo'>
                  <image class='poster image-height' :src="itemName.coverPath"
                    v-bind:style="{width:itemName.width+ 'px'}">
                  </image>
                  <view class='cover-video'></view>
                  <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                </view>
              </view>
              <view :class="{img:true,hide:itemName.videoSeconds==10}">
                <image :src="itemName.src" lazy-load="true" class="videoImg image-height"
                  v-bind:style="{width:itemName.width+ 'rpx'}"></image>
              </view>
              <text v-if="itemName.isShow" class="text-cover1">{{itemName.content}}</text>
              <text v-if="!(itemName.isShow)" class='text-cover text-cover1'></text>
              <view class='browse'>
                <image src='/static/images/bofangliang.png'></image>
                <text>{{itemName.playedTime}}</text>
              </view>
            </view>
          </view>

          <view class='share'>
            <view>
              <button hover-class='none' open-type="share" :data-id='itemName.id'>
                <image src='/static/images/btn-nor-fenxiang.png'></image>
              </button>
            </view>
            <view @click='goVideo' :data-id='itemName.id' :data-index='index'>
              <image src="/static/images/btn-new.png"></image>
              <text> {{itemName.commentTime}}</text>
            </view>
            <view :data-index='index' @click='dianzan'>
              <image src="/static/images/btn-nor-dianzan.png" :class="[itemName.dianzan?'hide':'']" :data-index='index'>
              </image>
              <image src="/static/images/btn-sel-dianzan.png" :class="[itemName.dianzan?'':'hide']" :data-index='index'>
              </image>
              <text> {{itemName.rateTime}}</text>
            </view>
          </view>
        </block>

      </view>
      <view :class="{loading:true,hide:more==1}">
        <icon class='iconfont icon-jiazaizhong'></icon>正在加载...
      </view>
    </view>
    <!-- 最新结束 -->

    <!-- 关注开始 -->
    <view :class="[_num==1||_num==2?'hide':'']">
      <view class='header'>
        <view class='news-header'>
          <text>推荐关注</text>
        </view>
        <view>
          <block v-for="(itemName,index) in tuijian" :key="index">
            <view class='personal'>
              <image :src='itemName.face_image' @click='goHomepage' :data-id='itemName.id'></image>
              <view class='name' @click='goHomepage' :data-id='itemName.id'>
                <text class='userName'>{{itemName.name}}</text>
                <text class='time'>{{itemName.asign}}</text>
              </view>
              <text :class="{follow:true,hide:itemName.follow}" @click='getfollowList' :data-id='itemName.id'
                :data-index='index'>关注</text>
              <text :class="{follow:true, cance:true,hide:itemName.follow}">已关注</text>
            </view>
          </block>
        </view>
      </view>

      <view class='main-follow header'>
        <view class='news-header'>
          <text>我的关注</text>
        </view>
      </view>
      <view>
        <view style="display:none">
          <image v-for="(item,index) in newfollow" :key="index" :src="item.coverPath" @load="onguanzhu">
          </image>
        </view>
        <block v-for="(itemName,index) in follow" :key="index">
          <view class='personal'>
            <image :src='itemName.faceImage' lazy-load="true" @click='goHomepage' :data-id='itemName.userid'>
            </image>
            <view class='name' @click='goHomepage' :data-id='itemName.userid'>
              <text class='userName'>{{itemName.name}}</text>
              <view class='enti'>
                <view class='time'>
                  <image src='/static/images/time.png'></image>
                  <text>{{itemName.createTime}}</text>
                </view>
                <view class='address'>
                  <image src='/static/images/weizhi.png'></image>
                  <text>{{itemName.city}}</text>
                </view>
              </view>
            </view>

            <view class='video' @click='goVideo' :data-id='itemName.id' :data-index='index'>
              <view :class="{myVideo:true,hide:itemName.videoSeconds==0}">
                <view class='coverVideo'>
                  <image :src="itemName.coverPath" lazy-load="true" class="poster image-height"
                    v-bind:style="{width:itemName.width+ 'px'}"></image>
                  </image>
                  <view class='cover-video'></view>
                  <image class='iconImg' src='/static/home-icons/icon-bofang.png'></image>
                </view>
              </view>
              <view :class="{img:true,hide:itemName.videoSeconds==10}">
                <image class="videoImg image-height" :src="itemName.coverPath"
                  v-bind:style="{width:itemName.width+'px'}">
                </image>
              </view>
              <text v-if="itemName.isShow" class="text-cover1">{{itemName.text}}</text>
              <text v-if="!(itemName.isShow)" class='text-cover text-cover1'></text>
              <view class='browse'>
                <image src='/static/images/bofangliang.png'></image>
                <text>{{itemName.playedTime}}</text>
              </view>
            </view>
          </view>
          <view class='share'>
            <view @click='' :data-id='itemName.id' :data-index='index'>
              <button hover-class='none' open-type="share" :data-id='itemName.id'>
                <image src='/static/images/btn-nor-fenxiang.png'></image>
              </button>
            </view>
            <view @click='goVideo' :data-id='itemName.id'>
              <image src='/static/images/btn-new.png'></image>
              <text> {{itemName.commentTime}}</text>
            </view>
            <view :data-index='index' @click='dianZan'>
              <image src='/static/images/btn-nor-dianzan.png' :class="[itemName.dianzan?'hide':'']" :data-index='index'>
              </image>
              <image src='/static/images/btn-sel-dianzan.png' :class="[itemName.dianzan?'':'hide']" :data-index='index'>
              </image>
              <text> {{itemName.rateTime}}</text>
            </view>
          </view>
        </block>
      </view>
      <view :class="{loading:true,hide: iMore==1 || iMore==3}">
        <icon class='iconfont icon-jiazaizhong'></icon>正在加载...
      </view>
      <view :class="{loading:true,hide: iMore==1 || iMore==3}">
        没有更多数据了
      </view>
    </view>
    <!-- 关注结束 -->

    <view class="foot-empty">

    </view>
    <view class="foot">
      <view class='button' @click='goUpload'>
        <view class='inside'>
          <!-- <icon class='iconfont icon-shangchuan'></icon> -->
          <uni-icons color="#fff" size="30" type="camera-filled"></uni-icons>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  // 1. 按需导入 mapMutations 辅助函数
  import {
    mapGetters,
    mapMutations,
    mapState
  } from 'vuex'
  export default {
    data() {
      return {
        padtop: 100,
        top: 0,
        shadow: 0,
        _num: 1,
        text1: '路况',
        text2: '风光',
        text3: '互助',
        text4: '曝光',
        text5: '其他',
        url: './video/video',
        tuijianPage: 1,
        page: 1,
        pageSize: 5,
        guanzhuPage: 1,
        guanzhuPageSize: 5,
        video: [],
        rows: [],
        newrows: [],
        follow: [],
        newfollow: [],
        // newUrl: app.serverUrl,
        videoSeconds: [],
        a: 0,
        more: '',
        index: 1,
        show: true,
        firstscroll: 0,
        scrollH: 0,
        imgWidth: 0,
        loadingCount: 0,
        col1H: 0,
        col2H: 0,

        selNum: 1,
        lukuangimages: [],
        lukuangcol1: [],
        lukuangcol2: [],
        fengguangimages: [],
        fengguangcol1: [],
        fengguangcol2: [],
        huzhuimages: [],
        huzhucol1: [],
        huzhucol2: [],
        baoguangimages: [],
        baoguangcol1: [],
        baoguangcol2: [],
        qitaimages: [],
        qitacol1: [],
        qitacol2: [],
      };
    },
    onLoad(options) {
      let _this = this
      console.log("options-_num", options._num)
      if (options) {
        if (options._num) {
          var _num = options._num
          this.pic = options.pic
        } else {
          var _num = 1
        }
      } else {
        var _num = 1
      }
      // this.userInfo = app.globalData.userInfo
      this._num = _num
      uni.getSystemInfo({
        success: (res) => {
          _this.imgWidth = res.windowWidth * 0.48;
        }
      })
      if (_this._num == 1) {
        _this.scrollH = 0
        _this.loadingCount = 0
        _this.lukuangcol1 = []
        _this.lukuangcol2 = []
        _this.col1H = 0
        _this.col2H = 0
        _this.tuijianPage = 1
        _this.selNum = 1
        _this.index = 1
        _this.lukuang()
      }
    },
    onShow() {
      this.showList()
    },
    methods: {

      // 把 m_user 模块中的 updateRedirectInfo 方法映射到当前页面中使用
      ...mapMutations('m_user', ['updateRedirectInfo']),

      goFenxiang(e) {
        if (this.land) {
          wx.navigateTo({
            url: '/subpkg/share/share',
          })
        } else {
          wx.navigateTo({
            url: '/subpkg/login/login',
          })
        }
      },

      onPress(e) {
        var selnum = e.currentTarget.dataset.index
        if (selnum == 2) {
          this.fengguangcol1 = []
          this.fengguangcol2 = []
          this.clsdate()
          this.fengguang()
        } else if (selnum == 3) {
          this.huzhucol1 = []
          this.huzhucol2 = []
          this.clsdate()
          this.huzhu()
        } else if (selnum == 4) {
          this.baoguangcol1 = []
          this.baoguangcol2 = []
          console.log("11")
          this.clsdate()
          this.baoguang()
        } else if (selnum == 5) {
          this.qitacol1 = []
          this.qitacol2 = []
          this.clsdate()
          this.qita()
        } else if (selnum == 1) {
          this.lukuangcol1 = []
          this.lukuangcol2 = []
          this.clsdate()
          this.lukuang()
        }
        this.index = selnum
        this.selNum = selnum
      },
      clsdate() {
        this.scrollH = 0
        this.loadingCount = 0
        this.col1H = 0
        this.col2H = 0
        this.tuijianPage = 1
      },

      async showList() {
        // var headerUserId = wx.getStorageSync('userId');
        // var openid = wx.getStorageSync('openid');
        // var userToken = wx.getStorageSync('userToken');
        var that = this
        var headerUserId = '225'
        var userToken = '83bcc158-e00c-4b3b-9517-3d829f79648e'
        var openid = 'opBvz1Qxl8lo40xGJrddRtjEqjwU'
        const {
          data: res
        } = await uni.$http.post('/user/isExist?openid=' + openid)
        if (res.status !== 200) {
          return uni.showToast({
            title: '数据请求失败！',
            duration: 1500,
            icon: 'none',
          })
        }
        if (res.data) {
          this.land = true
        } else {
          this.land = false
        }
        console.log("showList-that._num", that._num)
        if (that._num == 2) {
          this.show = false
          this.padtop = 40
          this.top = 0
          this.shadow = 0
          this.more = 1
          this.isLastPage = false
          this.rows = []
          this.newrows = []
          this.page = 1
          this.loadingCount = 0
          that.requestMore()
        }
      },
      showSearch(e) {
        console.log(e)
        uni.navigateTo({
          url: '/subpkg/search/search'
        })
      },

      // 获取用户信息
      async goHomepage(e) {
        var id = e.currentTarget.dataset.id;
        // var openid = uni.getStorageSync('openid')
        var openid = "opBvz1Qxl8lo40xGJrddRtjEqjwU"
        const {
          data: res
        } = await uni.$http.post('/user/isExist?openid=' + openid);
        if (res.status !== 200) return uni.$showMsg()
        if (res.data.data) {
          uni.navigateTo({
            url: 'subpkg/follow/follow?id=' + id,
          })
        } else {
          uni.navigateTo({
            url: 'subpkg/login/login',
          })
        }
      },

      goUpload(e) {
        uni.switchTab({
          url: '/pages/upload/upload'
        })
      },

      goVideo(e) {
        var that = this
        var id = e.currentTarget.dataset.id
        var index = e.currentTarget.dataset.index
        // console.log("goVideo._num", that._num)
        if (that._num == 2) {
          var rows = that.rows
          rows[index].playedTime = rows[index].playedTime + 1
          this.rows = rows
        } else if (that._num == 3) {
          var follow = that.follow
          follow[index].playedTime = follow[index].playedTime + 1
          this.follow = follow
        } else if (that._num == 1) {
          if (that.selNum == 1) {
            var lukuangcol1 = that.lukuangcol1
            lukuangcol1[index].playedTime = lukuangcol1[index].playedTime + 1
            this.lukuangcol1 = lukuangcol1
          } else if (that.selNum == 2) {
            var fengguangcol1 = that.fengguangcol1
            fengguangcol1[index].playedTime = fengguangcol1[index].playedTime + 1
            this.fengguangcol1 = fengguangcol1
          } else if (that.selNum == 3) {
            var huzhucol1 = that.huzhucol1
            huzhucol1[index].playedTime = huzhucol1[index].playedTime + 1
            this.huzhucol1 = huzhucol1
          } else if (that.selNum == 4) {
            var baoguangcol1 = that.baoguangcol1
            baoguangcol1[index].playedTime = baoguangcol1[index].playedTime + 1
            this.baoguangcol1 = baoguangcol1
          } else if (that.selNum == 5) {
            var qitacol1 = that.qitacol1
            qitacol1[index].playedTime = qitacol1[index].playedTime + 1
            this.qitacol1 = qitacol1
          }
        }
        uni.navigateTo({
          url: '/subpkg/video/video?id=' + id,
        })
      },
      goVIdoe(e) {
        var that = this
        var id = e.currentTarget.dataset.id
        var index = e.currentTarget.dataset.index
        if (that.selNum == 1) {
          var lukuangcol2 = that.lukuangcol2
          lukuangcol2[index].playedTime = lukuangcol2[index].playedTime + 1
          this.lukuangcol2 = lukuangcol2
        } else if (that.selNum == 2) {
          var fengguangcol2 = that.fengguangcol2
          fengguangcol2[index].playedTime = fengguangcol2[index].playedTime + 1
          this.fengguangcol2 = fengguangcol2
        } else if (that.selNum == 3) {
          var huzhucol2 = that.huzhucol2
          huzhucol2[index].playedTime = huzhucol2[index].playedTime + 1
          this.huzhucol2 = huzhucol2
        } else if (that.selNum == 4) {
          var baoguangcol2 = that.baoguangcol2
          baoguangcol2[index].playedTime = baoguangcol2[index].playedTime + 1
          this.baoguangcol2 = baoguangcol2
        } else if (that.selNum == 5) {
          var qitacol2 = that.qitacol2
          qitacol2[index].playedTime = qitacol2[index].playedTime + 1

          this.qitacol2 = qitacol2
        }
        uni.navigateTo({
          url: 'subpkg/video/video?id=' + id,
        })
      },

      async getfollowList(e) {
        var that = this
        // var url = app.serverUrl
        var index = e.currentTarget.dataset.index
        var tuijian = that.data.tuijian
        // var headerUserId = wx.getStorageSync('userId');
        // var userToken = wx.getStorageSync('userToken');
        var headerUserId = '225'
        var userToken = '83bcc158-e00c-4b3b-9517-3d829f79648e'
        // var openid = 'opBvz1Qxl8lo40xGJrddRtjEqjwU'
        var followId = tuijian[index].id
        const {
          data: res
        } = await uni.$http.post('/fans/addFollow?userId=' + headerUserId + '&followId=' + followId)
        if (res.status !== 200) return uni.$showMsg()
        tuijian[index].follow = 'ture'
        this.tuijian = tuijian
      },


      onLukuangLoad(e) {
        var that = this
        let imageId = e.currentTarget.id;
        let oImgW = e.detail.width; //图片原始宽度
        let oImgH = e.detail.height; //图片原始高度
        let imgWidth = this.imgWidth; //图片设置的宽度
        //比例计算
        let scale = imgWidth / oImgW;
        let imgHeight = oImgH * scale; //自适应高度
        let images = this.lukuangimages;
        let imageObj = null;
        for (let i = 0; i < images.length; i++) {
          let img = images[i];
          if (img.id == imageId) {
            imageObj = img;
            break;
          }
        }
        if (imgHeight == null) {
          imgHeight = 0
        }
        imageObj.height = imgHeight;
        let loadingCount = this.loadingCount - 1;
        let col1 = that.lukuangcol1;
        let col2 = that.lukuangcol2
        let col1H = that.col1H
        let col2H = that.col2H
        //判断当前图片添加到左列还是右列
        if (col1H <= col2H) {
          col1H += imgHeight;
          col1.push(imageObj);
        } else {
          col2H += imgHeight;
          col2.push(imageObj);
        }
        for (var i in col1) {
          if (col1[i].height == null) {
            col1[i].height = 0
          }
        }
        for (var i in col2) {
          if (col2[i].height == null) {
            col2[i].height = 0
          }
        }
        this.loadingCount = loadingCount
        this.lukuangcol1 = col1
        this.lukuangcol2 = col2
        this.col1H = col1H
        this.col2H = col2H
        //当前这组图片已加载完毕，则清空图片临时加载区域的内容
        if (!loadingCount) {
          this.lukuangimages = []
        }
      },
      async lukuang() {
        var that = this
        const {
          data: res
        } = await uni.$http.get('/video/toIndexHotDetail', {
          type: 1,
          page: this.tuijianPage,
          pageSize: 10
        })
        if (res.status !== 200) return uni.$showMsg()
        if (res.data.rows.length < 10) {
          // 没有数据了，已经是最后一页
          if (this.tuijianPage == 1) {
            var more = 3
          } else {
            var more = 1
          }
          this.more = more
          this.lukuangPage = true
        }
        var src = res.data.rows
        var images = this.lukuangimages
        for (var i in src) {
          if (src[i].content == '') {
            var isShow = false
          } else {
            var isShow = true
          }
          var img = {
            coverPath: src[i].coverPath,
            id: src[i].videoid,
            height: 0,
            playedTime: src[i].playedTime,
            content: src[i].content,
            videoSeconds: src[i].videoSeconds,
            isShow: isShow
          }
          images.push(img)
        }
        this.loadingCount = images.length
        this.lukuangimages = images
        uni.hideLoading()
      },

      onBaoguangLoad(e) {
        var that = this
        let imageId = e.currentTarget.id;
        let oImgW = e.detail.width; //图片原始宽度
        let oImgH = e.detail.height; //图片原始高度
        let imgWidth = that.imgWidth; //图片设置的宽度
        //比例计算
        let scale = imgWidth / oImgW;
        let imgHeight = oImgH * scale; //自适应高度
        let images = that.baoguangimages;
        let imageObj = null;
        for (let i = 0; i < images.length; i++) {
          let img = images[i];
          if (img.id == imageId) {
            imageObj = img;
            break;
          }
        }
        if (imgHeight == null) {
          imgHeight = 0
        }
        imageObj.height = imgHeight;
        let loadingCount = that.loadingCount - 1
        let col1 = that.baoguangcol1
        let col2 = that.baoguangcol2
        let col1H = that.col1H
        let col2H = that.col2H
        //判断当前图片添加到左列还是右列
        if (col1H <= col2H) {
          col1H += imgHeight;
          col1.push(imageObj);
        } else {
          col2H += imgHeight;
          col2.push(imageObj);
        }
        for (var i in col1) {
          if (col1[i].height == null) {
            col1[i].height = 0
          }
        }
        for (var i in col2) {
          if (col2[i].height == null) {
            col2[i].height = 0
          }
        }
        this.loadingCount = loadingCount
        this.baoguangcol1 = col1
        this.baoguangcol2 = col2
        this.col1H = col1H
        this.col2H = col2H
        //当前这组图片已加载完毕，则清空图片临时加载区域的内容
        if (!loadingCount) {
          this.baoguangimages = []
        }
      },
      async baoguang() {
        var that = this
        const {
          data: res
        } = await uni.$http.get('/video/toIndexHotDetail', { //参数
          type: 4,
          page: that.tuijianPage,
          pageSize: 10
        })

        if (res.status !== 200) return uni.$showMsg()

        if (res.data.rows.length < 10) {
          // 没有数据了，已经是最后一页
          if (that.tuijianPage == 1) {
            var more = 3
          } else {
            var more = 1
          }
          that.more = more
          that.baoguangPage = true
        }
        var src = res.data.rows
        var images = that.baoguangimages
        for (var i in src) {
          if (src[i].content == '') {
            var isShow = false
          } else {
            var isShow = true
          }
          var img = {
            coverPath: src[i].coverPath,
            id: src[i].videoid,
            height: 0,
            playedTime: src[i].playedTime,
            content: src[i].content,
            videoSeconds: src[i].videoSeconds,
            isShow: isShow
          }
          images.push(img)
        }
        that.loadingCount = images.length
        that.baoguangimages = images
      },

      onFengguangLoad(e) {
        var that = this
        let imageId = e.currentTarget.id;
        let oImgW = e.detail.width; //图片原始宽度
        let oImgH = e.detail.height; //图片原始高度
        let imgWidth = this.imgWidth; //图片设置的宽度
        //比例计算
        let scale = imgWidth / oImgW;
        let imgHeight = oImgH * scale; //自适应高度
        let images = this.fengguangimages;
        let imageObj = null;
        for (let i = 0; i < images.length; i++) {
          let img = images[i];
          if (img.id == imageId) {
            imageObj = img;
            break;
          }
        }
        if (imgHeight == null) {
          imgHeight = 0
        }
        imageObj.height = imgHeight;
        let loadingCount = this.loadingCount - 1;
        let col1 = that.fengguangcol1;
        let col2 = that.fengguangcol2
        let col1H = that.col1H
        let col2H = that.col2H
        //判断当前图片添加到左列还是右列
        if (col1H <= col2H) {
          col1H += imgHeight;
          col1.push(imageObj);
        } else {
          col2H += imgHeight;
          col2.push(imageObj);
        }
        for (var i in col1) {
          if (col1[i].height == null) {
            col1[i].height = 0
          }
        }
        for (var i in col2) {
          if (col2[i].height == null) {
            col2[i].height = 0
          }
        }

        this.loadingCount = loadingCount
        this.fengguangcol1 = col1
        this.fengguangcol2 = col2
        this.col1H = col1H
        this.col2H = col2H

        //当前这组图片已加载完毕，则清空图片临时加载区域的内容
        if (!loadingCount) {
          // that.setData({
          this.fengguangimages = []
          // })
        }
      },
      async fengguang() {
        var that = this
        const {
          data: res
        } = await uni.$http.get('/video/toIndexHotDetail', { //参数
          type: 2,
          page: that.tuijianPage,
          pageSize: 10
        })

        if (res.status !== 200) return uni.$showMsg()
        if (res.data.rows.length < 10) {
          // 没有数据了，已经是最后一页
          if (that.tuijianPage == 1) {
            var more = 3
          } else {
            var more = 1
          }
          this.more = more
          this.fenguangPage = true
        }
        var src = res.data.rows
        var images = that.fengguangimages
        for (var i in src) {
          if (src[i].content == '') {
            var isShow = false
          } else {
            var isShow = true
          }
          var img = {
            coverPath: src[i].coverPath,
            id: src[i].videoid,
            height: 0,
            playedTime: src[i].playedTime,
            content: src[i].content,
            videoSeconds: src[i].videoSeconds,
            isShow: isShow
          }
          images.push(img)
        }
        this.loadingCount = images.length
        this.fengguangimages = images
      },

      onHuzhuLoad(e) {
        var that = this
        let imageId = e.currentTarget.id;
        let oImgW = e.detail.width; //图片原始宽度
        let oImgH = e.detail.height; //图片原始高度
        let imgWidth = this.imgWidth; //图片设置的宽度
        //比例计算
        let scale = imgWidth / oImgW;
        let imgHeight = oImgH * scale; //自适应高度
        let images = this.huzhuimages;
        let imageObj = null;
        for (let i = 0; i < images.length; i++) {
          let img = images[i];
          if (img.id == imageId) {
            imageObj = img;
            break;
          }
        }
        if (imgHeight == null) {
          imgHeight = 0
        }
        imageObj.height = imgHeight;
        let loadingCount = this.loadingCount - 1;
        let col1 = that.huzhucol1;
        let col2 = that.huzhucol2
        let col1H = that.col1H
        let col2H = that.col2H
        //判断当前图片添加到左列还是右列
        if (col1H <= col2H) {
          col1H += imgHeight;
          col1.push(imageObj);
        } else {
          col2H += imgHeight;
          col2.push(imageObj);
        }
        for (var i in col1) {
          if (col1[i].height == null) {
            col1[i].height = 0
          }
        }
        for (var i in col2) {
          if (col2[i].height == null) {
            col2[i].height = 0
          }
        }
        // that.setData({
        this.loadingCount = loadingCount
        this.huzhucol1 = col1
        this.huzhucol2 = col2
        this.col1H = col1H
        this.col2H = col2H
        // })
        // 当前这组图片已加载完毕，则清空图片临时加载区域的内容
        if (!loadingCount) {
          // that.setData({
          this.huzhuimages = []
          // })
        }
      },
      async huzhu() {
        var that = this
        const {
          data: res
        } = await uni.$http.get('/video/toIndexHotDetail', { //参数
          type: 3,
          page: that.tuijianPage,
          pageSize: 10
        })

        if (res.status !== 200) return uni.$showMsg()

        if (res.data.rows.length < 10) {
          // 没有数据了，已经是最后一页
          if (that.tuijianPage == 1) {
            var more = 3
          } else {
            var more = 1
          }
          this.more = more
          this.huzhuPage = true
        }
        var src = res.data.rows
        var images = that.huzhuimages
        for (var i in src) {
          if (src[i].content == '') {
            var isShow = false
          } else {
            var isShow = true
          }
          var img = {
            coverPath: src[i].coverPath,
            id: src[i].videoid,
            height: 0,
            playedTime: src[i].playedTime,
            content: src[i].content,
            videoSeconds: src[i].videoSeconds,
            isShow: isShow
          }
          images.push(img)
        }
        this.loadingCount = images.length
        this.huzhuimages = images
      },


      onQitaLoad(e) {
        var that = this
        let imageId = e.currentTarget.id;
        let oImgW = e.detail.width; //图片原始宽度
        let oImgH = e.detail.height; //图片原始高度
        let imgWidth = that.imgWidth; //图片设置的宽度
        //比例计算
        let scale = imgWidth / oImgW;
        let imgHeight = oImgH * scale; //自适应高度
        let images = that.qitaimages;
        let imageObj = null;
        for (let i = 0; i < images.length; i++) {
          let img = images[i];
          if (img.id == imageId) {
            imageObj = img;
            break;
          }
        }
        if (imgHeight == null) {
          imgHeight = 0
        }
        imageObj.height = imgHeight;
        let loadingCount = that.loadingCount - 1;
        let col1 = that.qitacol1;
        let col2 = that.qitacol2
        let col1H = that.col1H
        let col2H = that.col2H
        //判断当前图片添加到左列还是右列
        if (col1H <= col2H) {
          col1H += imgHeight;
          col1.push(imageObj);
        } else {
          col2H += imgHeight;
          col2.push(imageObj);
        }
        for (var i in col1) {
          if (col1[i].height == null) {
            col1[i].height = 0
          }
        }
        for (var i in col2) {
          if (col2[i].height == null) {
            col2[i].height = 0
          }
        }
        // that.setData({
        this.loadingCount = loadingCount
        this.qitacol1 = col1
        this.qitacol2 = col2
        this.col1H = col1H
        this.col2H = col2H
        // })
        //当前这组图片已加载完毕，则清空图片临时加载区域的内容
        if (!loadingCount) {
          // that.setData({
          this.qitaimages = []
          // })
        }
      },
      async qita() {
        var that = this
        const {
          data: res
        } = await uni.$http.get('/video/toIndexHotDetail', {
          type: 5,
          page: that.tuijianPage,
          pageSize: 10
        })
        if (res.status !== 200) {
          return uni.showToast({
            title: '数据请求失败！',
            duration: 1500,
            icon: 'none',
          })
        }
        if (res.data.rows.length < 10) {
          // 没有数据了，已经是最后一页
          if (that.tuijianPage == 1) {
            var more = 3
          } else {
            var more = 1
          }
          that.more = more
          that.qitaPage = true
          var src = res.data.rows
          var images = that.qitaimages
          for (var i in src) {
            if (src[i].content == '') {
              var isShow = false
            } else {
              var isShow = true
            }
            var img = {
              coverPath: src[i].coverPath,
              id: src[i].videoid,
              height: 0,
              playedTime: src[i].playedTime,
              content: src[i].content,
              videoSeconds: src[i].videoSeconds,
              isShow: isShow
            }
            images.push(img)
          }
          that.loadingCount = images.length
          that.qitaimages = images
        }
      },


      onzuixin(e) {
        var that = this
        let imageId = e.currentTarget.id;
        let oImgW = e.detail.width; //图片原始宽度
        let oImgH = e.detail.height; //图片原始高度
        //比例计算
        let scale = 375 / oImgH;
        let imgWidth = oImgW * scale; //自适应高度zz
        let images = this.newrows;
        let imageObj = null;
        for (let i = 0; i < images.length; i++) {
          let img = images[i];
          if (img.id == imageId) {
            imageObj = img;
            break;
          }
        }
        if (imgWidth == null) {
          imgWidth = 0
        }
        imageObj.width = imgWidth;
        let loadingCount = this.loadingCount - 1;
        let rows = that.rows;
        rows.push(imageObj)
        if (rows.length > 1) {
          for (var i = 0; i < rows.length - 1; i++) {
            for (var j = 0; j < rows.length - 1 - i; j++) {
              if (rows[j].id < rows[j + 1].id) {
                var s = rows[j];
                rows[j] = rows[j + 1];
                rows[j + 1] = s;
              }
              if (rows[j].id == rows[j + 1].id) {
                //如果第一个等于第二个，splice方法删除第二个
                rows.splice(j, 1);
                j--;
              }
            }
            if (rows[i].width == null) {
              rows[i].width = 0
            }
          }
        }
        this.loadingCount = loadingCount
        this.rows = rows
        //当前这组图片已加载完毕，则清空图片临时加载区域的内容
        if (!loadingCount) {
          this.loadingCount = 0
          this.newrows = []
        }
      },

      onguanzhu(e) {
        var that = this
        let imageId = e.currentTarget.id;
        let oImgW = e.detail.width; //图片原始宽度
        let oImgH = e.detail.height; //图片原始高度
        //比例计算
        let scale = 375 / oImgH;
        let imgWidth = oImgW * scale; //自适应高度zz
        let images = this.newfollow;
        let imageObj = null;
        for (let i = 0; i < images.length; i++) {
          let img = images[i];
          if (img.id == imageId) {
            imageObj = img;
            break;
          }
        }
        if (imgWidth == null) {
          imgWidth = 0
        }
        imageObj.width = imgWidth;
        let loadingCount = this.loadingCount - 1;
        let follow = that.follow;
        follow.push(imageObj)
        if (follow.length > 1) {
          for (var i = 0; i < follow.length - 1; i++) {
            for (var j = 0; j < follow.length - 1 - i; j++) {
              if (follow[j].id < follow[j + 1].id) {
                var s = follow[j];
                follow[j] = follow[j + 1];
                follow[j + 1] = s;
              }
              if (follow[j].id == follow[j + 1].id) {
                //如果第一个等于第二个，splice方法删除第二个
                follow.splice(j, 1);
                j--;
              }
            }
          }
        }
        this.loadingCount = loadingCount
        this.follow = follow
        // 当前这组图片已加载完毕，则清空图片临时加载区域的内容
        if (!loadingCount) {
          this.loadingCount = 0
          this.newfollow = []
        }
      },
      async guanzhu() {
        // 关注数据
        var that = this
        if (that.land) {
          // var headerUserId = wx.getStorageSync('userId');
          // var userToken = wx.getStorageSync('userToken');
          var headerUserId = '225'
          var userToken = '83bcc158-e00c-4b3b-9517-3d829f79648e'
          // console.log("11")
          const res = await uni.$http.get('/user/' + headerUserId)
          // console.log("res1",res)
          if (res.statusCode !== 200) return uni.$showMsg()
          // console.log("res1",res.data)
          this.user = res.data
          // console.log("this.user",this.user)
          // console.log("headerUserId",headerUserId)
          const res2 = await uni.$http.get('/fans/recommend?userId=' + headerUserId)
          // console.log("res2",res2)
          if (res2.statusCode !== 200) return uni.$showMsg()
          var tuijian = res2.data.data
          // console.log("res2",res2.data)
          for (var i in tuijian) {
            if (tuijian[i].asign == '') {
              tuijian[i].asign = '暂无签名'
            }
          }
          this.tuijian = tuijian
          // console.log(" this.tuijian ", this.tuijian)
          var page = that.guanzhuPage
          var pageSize = that.guanzhuPageSize

          const res3 = await uni.$http.get('/video/getFollowVideo?userId=' + headerUserId + '&page=' + page +
            '&pageSize=' +
            pageSize)
          console.log("res3", res3)
          if (res3.statusCode !== 200) return uni.$showMsg()
          console.log("res3", res3)
          if (res3.data.data.rows.length < that.guanzhuPageSize) {
            // 没有数据了，已经是最后一页
            if (that.guanzhuPage == 1) {
              var iMore = 3
            } else {
              var iMore = 1
            }
            this.iMore = iMore
            this.isLastPage = true
          }
          var newFollow = res3.data.data.rows
          var newfollow = that.follow
          for (var index in newFollow) {
            newFollow[index].sumvo.createTime = this.$mUtils.timeago(newFollow[index].sumvo.createTime)
            if (newFollow[index].sumvo.city == '' || newFollow[index].sumvo.city == "[object Undefined]") {
              newFollow[index].sumvo.city = '保密'
            }
            if (newFollow[index].sumvo.createTime == undefined) {
              newFollow[index].sumvo.createTime = '刚刚'
            }
          }
          for (var i in newFollow) {
            if (newFollow[i].sumvo.content == '') {
              var isShow = false
            } else {
              var isShow = true
            }
            var id = newFollow[i].sumvo.videoid
            var dianzan = newFollow[i].israte
            var img = {
              coverPath: newFollow[i].sumvo.coverPath,
              id: newFollow[i].sumvo.videoid,
              width: 0,
              playedTime: newFollow[i].sumvo.playedTime,
              content: newFollow[i].sumvo.content,
              createTime: newFollow[i].sumvo.createTime,
              city: newFollow[i].sumvo.city,
              dist: newFollow[i].sumvo.dist,
              commentTime: newFollow[i].sumvo.commentTime,
              rateTime: newFollow[i].sumvo.rateTime,
              name: newFollow[i].sumvo.name,
              faceImage: newFollow[i].sumvo.faceImage,
              src: newFollow[i].sumvo.src,
              videoSeconds: newFollow[i].sumvo.videoSeconds,
              userid: newFollow[i].sumvo.userid,
              isShow: isShow,
              dianzan: dianzan
            }
            newfollow.push(img)
          }
          this.loadingCount = newfollow.length
          this.newfollow = newfollow
        } else {
          uni.navigateTo({
            url: '../login/login',
          })
        }
      },



      async requestMore(e) {
        //最新数据
        var that = this
        if (that.land) {
          var headerUserId = '225'
          // var headerUserId = wx.getStorageSync('userId');
          const {
            data: res
          } = await uni.$http.get('/video/toIndexNewWithUser', {
            userId: headerUserId,
            page: that.page,
            pageSize: 5
          })
          if (res.status !== 200) return uni.$showMsg()
          if (res.data.rows.length < 5) {
            // 没有数据了，已经是最后一页
            if (that.data.page == 1) {
              var more = 3
            } else {
              var more = 1
            }
            that.more = more
            that.isLastPage = true
          }
          var newRows = res.data.rows
          var newrows = that.newrows
          for (var index in newRows) {
            // newRows[index].sumvo.createTime = time.timeago(newRows[index].sumvo.createTime)
            newRows[index].sumvo.createTime = this.$mUtils.timeago(newRows[index].sumvo.createTime)
            if (newRows[index].sumvo.city == '' || newRows[index].sumvo.city == "[object Undefined]") {
              newRows[index].sumvo.city = '保密'
            }
            if (newRows[index].sumvo.createTime == undefined) {
              newRows[index].sumvo.createTime = '刚刚'
            }
          }
          for (var i in newRows) {
            if (newRows[i].sumvo.content == '') {
              var isShow = false
            } else {
              var isShow = true
            }
            var id = newRows[i].sumvo.videoid
            var dianzan = newRows[i].israte
            var img = {
              coverPath: newRows[i].sumvo.coverPath,
              id: newRows[i].sumvo.videoid,
              width: 0,
              playedTime: newRows[i].sumvo.playedTime,
              content: newRows[i].sumvo.content,
              createTime: newRows[i].sumvo.createTime,
              city: newRows[i].sumvo.city,
              dist: newRows[i].sumvo.dist,
              commentTime: newRows[i].sumvo.commentTime,
              rateTime: newRows[i].sumvo.rateTime,
              name: newRows[i].sumvo.name,
              faceImage: newRows[i].sumvo.faceImage,
              src: newRows[i].sumvo.src,
              videoSeconds: newRows[i].sumvo.videoSeconds,
              userid: newRows[i].sumvo.userid,
              isShow: isShow,
              dianzan: dianzan
            }
            newrows.push(img)
          }
          that.loadingCount = newrows.length
          that.newrows = newrows
          uni.hideLoading()
        } else {
          const {
            data: res
          } = await uni.$http.get('/video/toIndexNew', { //参数
            page: that.page,
            pageSize: 5
          })
          if (res.status !== 200) return uni.$showMsg()
          if (res.data.rows.length < 5) {
            // 没有数据了，已经是最后一页
            if (that.page == 1) {
              var more = 3
            } else {
              var more = 1
            }
            this.more = more
            this.isLastPage = true
          }
          var newRows = res.data.rows
          var newrows = that.newrows
          for (var index in newRows) {
            // newRows[index].createTime = time.timeago(newRows[index].createTime)
            newRows[index].createTime = this.$mUtils.timeago(newRows[index].createTime)
            if (newRows[index].city == '' || newRows[index].city == "[object Undefined]") {
              newRows[index].city = '保密'
            }
            if (newRows[index].createTime == undefined) {
              newRows[index].createTime = '刚刚'
            }
          }
          for (var i in newRows) {
            if (newRows[i].content == '') {
              var isShow = false
            } else {
              var isShow = true
            }
            var id = newRows[i].videoid
            var img = {
              coverPath: newRows[i].coverPath,
              id: newRows[i].videoid,
              width: 0,
              playedTime: newRows[i].playedTime,
              content: newRows[i].content,
              createTime: newRows[i].createTime,
              city: newRows[i].city,
              dist: newRows[i].dist,
              commentTime: newRows[i].commentTime,
              rateTime: newRows[i].rateTime,
              name: newRows[i].name,
              faceImage: newRows[i].faceImage,
              src: newRows[i].src,
              videoSeconds: newRows[i].videoSeconds,
              userid: newRows[i].userid,
              isShow: isShow,
            }
            newrows.push(img)
          }
          that.loadingCount = newrows.length
          that.newrows = newrows
          uni.hideLoading()
        }
      },

      onPageScroll(e) {
        var that = this
        var num = that._num
        console.log("onPageScroll._num", that._num)

        if (num == 1) {
          var lastscroll = e.scrollTop
          var firstscroll = that.firstscroll
          var salce = lastscroll - firstscroll
          // console.log(salce)
          // console.log(that.top)
          if (salce > 0) {
            var shadow = 0
            var top = that.top - salce
            if (top <= -60) {
              top = -60
              var shadow = 1
            }
            // that.setData({
            this.shadow = shadow
            this.top = top
            this.firstscroll = lastscroll
            // })
          } else if (salce <= 0) {
            var top = that.top - salce
            var shadow = 1
            if (top >= 0) {
              top = 0
              var shadow = 0
            }
            // that.setData({
            this.shadow = shadow
            this.top = top
            this.firstscroll = lastscroll
            // })
          }
        }
      },

      onSwitch(e) {
        var that = this
        var num = e.target.dataset.num
        console.log("onSwitch. num", e.target.dataset.num)

        if (num == 3) {
          this._num = num
          this.show = false
          this.padtop = 40
          this.top = 0
          this.shadow = 0
          this.page = 1
          this.rows = []
          this.guanzhu()
          uni.hideLoading()
        } else if (num == 2) {
          that._num = num
          that.show = false
          that.padtop = 40
          that.follow = []
          that.guanzhuPage = 1
          that.top = 0
          that.shadow = 0
          that.more = 3
          that.isLastPage = false
          that.rows = []
          that.newrows = []
          that.page = 1
          that.loadingCount = 0
          that.requestMore()
        } else {
          that._num = num
          that.show = true
          that.padtop = 100
          that.follow = []
          this.newfollow = []
          that.guanzhuPage = 1
          that.top = 0
          // that.shadow = 0
          that.more = 1
          that.isLastPage = false
          that.rows = []
          // that.newrows = []
          that.page = 1
          that.loadingCount = 0
          that.lukuang()
          uni.pageScrollTo({
            scrollTop: 0
          })
        }
      },

      async dianzan(e) {
        var that = this
        if (that.land) {
          var index = e.currentTarget.dataset.index
          // var headerUserId = wx.getStorageSync('userId');
          // var userToken = wx.getStorageSync('userToken');
          var headerUserId = '225'
          var userToken = 'e4e2acec-66e0-4abf-9649-a74a771ea417'
          var id = that.rows[index].id

          if (that.rows[index].dianzan) {
            const res = await uni.$http.delete('/video/deleteRate?videoId=' + id + '&userId=' + headerUserId)
            if (res.statusCode !== 200) return uni.$showMsg()
            // success: function(res) {
            // if (res.statusCode == 200 || res.data.status == 200) {
            var rows = that.rows
            uni.$showMsg({
              title: '取消点赞成功',
              icon: 'success',
              mask: true,
              duration: 1000
            })
            rows[index].rateTime = rows[index].rateTime - 1
            rows[index].dianzan = false
            this.rows = rows

          } else {
            const res = await uni.$http.post('/video/addRate?videoId=' + id + '&userId=' + headerUserId)
            if (res.statusCode !== 200) return uni.$showMsg()
            // if (res.statusCode == 200 || res.data.status == 200) {
            var rows = that.rows
            uni.$showMsg({
              title: '点赞成功',
              icon: 'success',
              mask: true,
              duration: 1000
            })
            rows[index].rateTime = rows[index].rateTime + 1
            rows[index].dianzan = true
            // that.setData({
            this.rows = rows
            // })
          }
        } else {
          wx.navigateTo({
            url: '../../login/login',
          })
        }
      },
      async dianZan(e) {
        var that = this
        if (that.land) {
          var index = e.currentTarget.dataset.index
          var nowdianzan = that.newdianzan[index]
          // var headerUserId = wx.getStorageSync('userId');
          // var userToken = wx.getStorageSync('userToken');
          var headerUserId = '225'
          var userToken = 'e4e2acec-66e0-4abf-9649-a74a771ea417'
          var id = that.follow[index].videoid
          if (nowdianzan) {
            const res = await uni.$http.delete('/video/deleteRate?videoId=' + id + '&userId=' + headerUserId)
            var newdianzan = that.newdianzan
            var follow = that.follow
            uni.$showMsg({
              title: '取消点赞成功',
              icon: 'success',
              mask: true,
              duration: 1000
            })
            newdianzan[index] = false
            follow[index].rateTime = follow[index].rateTime - 1
            this.newdianzan = newdianzan
            this.follow = follow
          } else {
            const res = await uni.$http.post('/video/addRate?videoId=' + id + '&userId=' + headerUserId)
            var newdianzan = that.newdianzan
            var follow = that.follow
            uni.$showMsg({
              title: '点赞成功',
              icon: 'success',
              mask: true,
              duration: 1000
            })
            newdianzan[index] = true
            follow[index].rateTime = follow[index].rateTime + 1
            this.newdianzan = newdianzan
            this.follow = follow
          }
        } else {
          uni.navigateTo({
            url: '/subpkg/login/login',
          })
        }
      },



    },


    onReady() {
      uni.hideLoading()
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {
      console.log("333")
      if (this._num == 2) {
        // 最后一页了，取消下拉功能
        if (this.isLastPage) {
          return
        }
        this.more = 0
        this.page = this.page + 1
        this.requestMore()
      } else if (this._num == 3) {
        // 最后一页了，取消下拉功能
        if (this.enLastPage) {
          return
        }
        this.iMore = 0
        this.guanzhuPage = this.guanzhuPage + 1
        this.guanzhu()
      } else if (this._num == 1) {
        if (this.selNum == 1) {
          // 最后一页了，取消下拉功能
          if (this.lukuangPage) {
            return
          }
          this.more = 0
          this.tuijianPage = this.tuijianPage + 1
          this.lukuang()
        } else if (this.selNum == 2) {
          // 最后一页了，取消下拉功能
          if (this.lukuangPage) {
            return
          }
          this.more = 0,
            this.tuijianPage = this.tuijianPage + 1
          this.fengguang()
        } else if (this.selNum == 3) {
          // 最后一页了，取消下拉功能
          if (this.huzhuPage) {
            return
          }
          this.more = 0
          this.tuijianPage = this.tuijianPage + 1
          this.huzhu()
        } else if (this.selNum == 4) {
          // 最后一页了，取消下拉功能
          if (this.baoguangPage) {
            return
          }
          this.more = 0
          this.tuijianPage = this.tuijianPage + 1
          this.baoguang()
        } else if (this.selNum == 5) {
          // 最后一页了，取消下拉功能
          if (this.qitaPage) {
            return
          }
          this.more = 0
          this.tuijianPage = this.tuijianPage + 1
          this.qita()
        }
      }
    },

    //转发
    onShareAppMessage: function(res) {
      var id = res.target.dataset.id
      return {
        title: '分享',
        path: '/pages/home/home?come=video&id=' + id,
        success: function(res) {
          // 转发成功
          uni.showToast({
            title: "分享成功",
            icon: 'success',
            duration: 2000
          })
        },
        fail: function(res) {
          // 分享失败
        },
      }
    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {
      if (this.pic == 100) {
        var pages = getCurrentPages();
        var currPage = pages[pages.length - 1]; //当前页面
        var prevPage = pages[pages.length - 2]; //上一个页面
        prevPage.setData({
          viNum: 3,
          selNum: 1,
          _num: 0,
          num: 1,
          delNum: 0,
          images: '',
          video: '',
          index: '',
          b: 0,
          select: 0,
        })
      }
    },

  }
</script>

<style lang="scss">
  .body {
    background-color: #f7f7f7;
  }

  .cur {
    font-weight: 700;
    font-size: 16px;
    border-bottom: 2px solid #008ce0;
  }

  .hide {
    display: none;
  }

  .nav-bar {
    position: fixed;
    left: 0;
    background-color: #fff;
    z-index: 999999;
  }

  .top {
    height: 100rpx;
    line-height: 100rpx;
    position: relative;
    top: 0;
    left: 0;
    width: 750rpx;
  }

  .box-shadow {
    box-shadow: 0 1rpx 1rpx 1rpx rgba(225, 223, 223, 0.3);
    /*for Android*/
    -webkit-box-shadow: 0px 1px 1px 1px rgba(225, 225, 223, 0.3);
  }


  .nav {
    padding: 0 80rpx;
    margin-bottom: 10rpx;
    height: 97rpx;
    line-height: 97rpx;
    font-size: 14px;
    background-color: #fff;
  }


  .select {
    display: inline-block;
    text-align: center;
    letter-spacing: 5rpx;
  }

  .select:first-of-type {
    margin-left: 100rpx;
  }

  .select:nth-of-type(2) {
    margin-left: 80rpx;
  }

  .select:last-of-type {
    margin-left: 80rpx;
  }


  .hot-select {
    width: 670rpx;
    padding: 26rpx 40rpx;
    height: 85rpx;
    line-height: 85rpx;
    background-color: #fff;

    text {
      width: 90rpx;
      margin-left: 32rpx;
      padding: 0 10rpx;
      display: inline-block;
      height: 52rpx;
      line-height: 52rpx;
      border-radius: 26rpx;
      font-size: 14px;
      background-color: #f8f8f8;
      color: #999;
      text-align: center;
    }

    text:first-of-type {
      margin-left: 0;
    }
  }

  .bgc {
    background-color: #008ce0 !important;
    color: #fff !important;
  }



  .showSearch {
    width: 70rpx;
    height: 70rpx;
    border-radius: 0;
    color: #666;
    position: absolute;
    top: 17rpx;
    left: 35rpx;
    z-index: 999999999999999999;

    image {
      width: 70rpx;
      height: 70rpx;
      border-radius: 35rpx;
    }
  }

  .search-top {
    width: 70rpx;
    height: 70rpx;
    line-height: 70rpx;
    border-radius: 0;
    color: #666;
    position: absolute;
    top: 13rpx;
    right: 35rpx;
    z-index: 999999999999999999;
  }

  .header {
    padding-top: 10rpx;
    background-color: #fff;
    margin-bottom: 21rpx;
  }

  .news-header {
    margin-top: 20rpx;
    padding-left: 30rpx;
    border-left: 2px solid #008ce0;
    position: relative;

    text {
      font-weight: 700;
    }
  }


  .margin_bottom {
    padding-bottom: 100rpx;
  }

  .show {
    display: block;
  }

  .newest {
    background-color: #f7f7f7;
  }

  .personal {
    background-color: #fff;
    padding: 42rpx 42rpx 0;
    position: relative;

    .personal-img {
      width: 100rpx;
      height: 100rpx;
      border-radius: 50rpx;
      background-color: #ccc;
      margin-top: 14rpx;
    }
  }

  // .personal {
  //   image {

  //   }
  // }
  .personal:last-of-type {
    padding-bottom: 48rpx;
  }

  .iconbofang {
    width: 60rpx;
    height: 60rpx;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }

  .iconbofang .iconImg {
    width: 60rpx;
    height: 60rpx;
  }

  .follow {
    font-size: 12px;
    height: 50rpx;
    line-height: 50rpx;
    padding: 0 30rpx;
    text-align: center;
    color: #008ce0;
    border: 1px solid #008ce0;
    border-radius: 10rpx;
    position: absolute;
    top: 70rpx;
    right: 33rpx;
  }

  .cance {
    color: #ccc;
    border-color: #ebebeb;
  }



  .name {
    width: 300rpx;
    position: absolute;
    top: 50rpx;
    left: 160rpx;
  }

  .userName {
    display: block;
    font-size: 14px;
    font-weight: 700;
    margin-top: 16rpx;
    margin-bottom: 12rpx;
  }

  .enti {
    width: 530rpx;

    text {
      color: #666;
    }
  }

  .time,
  .address {
    line-height: 30rpx;
    font-size: 12px;
    display: inline-block;
    color: #666;
  }

  .header .time {
    top: 66rpx;
  }

  .time {
    image {
      width: 27rpx;
      height: 27rpx;
      /* vertical-align: middle; */
      margin-right: 10rpx;
    }
  }

  .address {
    margin-left: 25rpx;

    image {
      width: 27rpx;
      height: 27rpx;
      /* vertical-align: middle; */
      margin-right: 10rpx;
    }
  }

  .myVideo {
    width: 666rpx;
    height: 384rpx;
    border-radius: 20rpx;
    position: relative;
  }

  .coverVideo {
    width: 666rpx;
    height: 384rpx;
    border-radius: 20rpx;
    position: absolute;
    top: 0;
    left: 0;
    background-color: #000;
    text-align: center;
    overflow: hidden;

    .iconImg {
      width: 100rpx;
      height: 100rpx;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }

    .cover-video {
      width: 666rpx;
      height: 384rpx;
      border-radius: 20rpx;
      position: absolute;
      top: 0;
      left: 0;
      background-color: rgba(209, 207, 207, 0.1);
    }
  }

  .video {
    width: 666rpx;
    border-radius: 20rpx;
    position: relative;
    margin-top: 36rpx;

    .img {
      width: 666rpx;
      height: 384rpx;
      overflow: hidden;
      text-align: center;
      background-color: #000;
      border-radius: 20rpx;
    }

    // text {

    // }

    .text-cover1 {
      font-size: 14px;
      height: 120rpx;
      line-height: 120rpx;
      padding-left: 15rpx;
    }

    .text-cover {
      height: 36rpx;
      line-height: 36rpx;
    }
  }



  .share {
    position: relative;
    border-top: 4rpx solid #ebebeb;
    height: 100rpx;
    line-height: 100rpx;
    color: #666;
    text-align: center;
    background-color: #fff;
    margin-bottom: 21rpx;
  }

  .share:first-child {
    margin-bottom: 0;
  }

  .share button {
    width: 100rpx;
    height: 100rpx;
    line-height: 100rpx;
    background-color: #fff;
  }

  .share image {
    width: 38rpx;
    height: 38rpx;
    vertical-align: middle;
  }

  .share text {
    font-size: 12px;
  }

  .share>view {
    width: 100rpx;
    height: 100rpx;
    line-height: 100rpx;
    position: absolute;
    top: 0;
  }

  .share>view:first-of-type {
    left: 68rpx;
  }

  .share>view:nth-of-type(2) {
    left: 50%;
    transform: translateX(-50%);
  }

  .share>view:last-of-type {
    right: 69rpx;
  }

  .share>view text {
    margin-left: 8rpx;
  }

  .newest {
    background-color: #f7f7f7;
  }

  .main-follow {
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .news {
    width: 100%;
    background-color: #fff;
    margin-top: 20rpx;
  }

  .news:first-of-type {
    margin-top: 0;
  }

  .news-header {
    margin-top: 20rpx;
    padding-left: 30rpx;
    border-left: 2px solid #008ce0;
    position: relative;
  }

  .news-header>text {
    font-weight: 700;
  }

  .news-hr {
    position: absolute;
    top: -20rpx;
    right: 30rpx;
  }

  .news-hr text {
    font-size: 12px;
    color: rgb(83, 82, 82);
    margin-right: 20rpx;
  }

  .news-hr icon {
    font-size: 12px;
    color: rgb(83, 82, 82);
    display: inline;
  }

  .hotNews-index>.newsPlay {
    width: 80rpx;
    height: 80rpx;
    position: absolute;
    top: 85rpx;
    left: 120rpx;
  }

  .hotNews-index>text {
    font-size: 10px;
  }


  .foot {
    width: 750rpx;
    height: 84rpx;
    position: fixed;
    bottom: 0;
    left: 0;
    background-color: #fff;
    box-shadow: 0 -1rpx 1rpx 1rpx rgba(225, 225, 223, 0.6);
    /*for Android*/
    -webkit-box-shadow: 0px -1px 1px 1px rgba(225, 225, 223, 0.6);
  }

  .foot .button {
    width: 120rpx;
    height: 120rpx;
    line-height: 120rpx;
    text-align: center;
    border-radius: 60rpx;
    background-color: #fff;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 -1rpx 1rpx 1rpx rgba(225, 225, 223, 0.6);
    /*for Android*/
    -webkit-box-shadow: 0px -1px 1px 1px rgba(225, 225, 223, 0.6);
  }

  .inside {
    width: 88rpx;
    height: 88rpx;
    line-height: 88rpx;
    border-radius: 44rpx;
    background-color: #008ce0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);


  }


  .loading {
    width: 750rpx;
    height: 80rpx;
    line-height: 80rpx;
    text-align: center;
    color: #999;
    font-size: 14px;
    background-color: #fff;
  }

  .foot-empty {
    width: 750rpx;
    height: 84rpx;
    background-color: #fff;
  }

  .browse {
    position: absolute;
    top: 20rpx;
    left: 20rpx;
  }

  .browse image {
    width: 60rpx;
    height: 42rpx;
    vertical-align: middle;
  }

  .browse text {
    font-size: 14px;
    color: #fff;
    text-shadow: 0 2rpx 2rpx #000;
    margin-left: 5rpx;
  }

  .news {
    width: 100%;
    background-color: #fff;
    margin-top: 20rpx;
  }

  .header {
    padding-top: 10rpx;
  }

  .news-header {
    margin-top: 20rpx;
    padding-left: 30rpx;
    border-left: 2px solid #008ce0;
    position: relative;
  }

  .news-header>text {
    font-weight: 700;
  }

  .news-hr {
    position: absolute;
    top: -20rpx;
    right: 30rpx;
  }

  .news-hr text {
    font-size: 12px;
    color: rgb(83, 82, 82);
    margin-right: 20rpx;
  }

  .news-hr icon {
    font-size: 12px;
    color: rgb(83, 82, 82);
    display: inline;
  }

  .img_item {
    width: 42.5%;
    margin-left: 5%;
    display: inline-block;
    vertical-align: top;
  }

  .img_item1 {
    width: 42.5%;
    margin-left: 5%;
    display: inline-block;
    vertical-align: top;
  }

  .left-img,
  .right-img {
    margin-top: 10%;
    position: relative;
    border-radius: 10rpx;
  }

  .left-img image,
  .right-img image {
    vertical-align: middle;
    border-radius: 10rpx;
  }

  .image-width {
    width: 100%;
  }

  .image-height {
    height: 100%;
  }

  .left-img>text,
  .right-img>text {
    display: block;
    font-size: 12px;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.5);
    position: absolute;
    border-radius: 0 0 10rpx 10rpx;
    bottom: 0;
    left: 0;
    padding-left: 5%;
    width: 95%;
    height: 60rpx;
    line-height: 60rpx;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hotNews-num {
    width: 200rpx;
    height: 60rpx;
    line-height: 60rpx;
    position: absolute;
    top: 0;
    left: 15rpx;
  }

  .hotNews-num image {
    width: 44rpx;
    height: 31rpx;
    vertical-align: middle;
  }

  .hotNews-num text {
    font-size: 11px;
    color: #fff;
    text-shadow: 0 2rpx 2rpx #000;
    margin-left: 3rpx;
  }

  .sel-bgc {
    background-color: #fff;
  }
</style>
